﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using StateGrid.User;
using StateGrid.MDBservice;
using System.Data.OleDb;
using System.Data;
using System.Data.SqlClient;

namespace StateGrid.UI
{
    /// <summary>
    /// Interaction logic for TranditionWizard.xaml
    /// </summary>
    public partial class AdvanceWizard : UserControl
    {
        private System.Windows.Forms.OpenFileDialog fileSource = new System.Windows.Forms.OpenFileDialog();
        private DataService service = new DataService();

        public AdvanceWizard()
        {
            InitializeComponent();
        }

        private void btnSourceFile_Click(object sender, RoutedEventArgs e)
        {
            fileSource.ShowDialog();

            if (fileSource.FileName != "")
            {
                foreach (string file in DataService.GetLocalTableList(fileSource.FileName))
                {
                    cmbTableList.Items.Add(file);
                }
            }
            cmbTableList.SelectedIndex = 0;
        }

        private void btnAnalyze_Click(object sender, RoutedEventArgs e)
        {
            if (service.OpenLocalFile(fileSource.FileName, cmbTableList.SelectedItem as string))
            {
                MessageBox.Show("表结构正确，可以正确操作");
            }
            else
            {
                MessageBox.Show(service.ErrorLog);
            }
        }
    }


}
